﻿using System;

namespace CardGamesLibrary.Cards
{
    public class FrenchDeckCard : Card
    {
        public FrenchDeckCard(Rank rank, Suite suite)
        {
            Rank = rank;
            Suite = suite;
        }

        public Rank Rank { get; set; }

        public Suite Suite { get; set; }

        public SuitColor Color
        {
            get
            {
                return ((int) Suite) % 2 == 0 ? SuitColor.Black : SuitColor.Red;
            }
        }

        public bool Reversed { get; private set; }

        public void Reverse()
        {
            Reversed = !Reversed;
        }

        public override string ToString()
        {
            var rank = "";
            var r = (int) Rank;
            if (r > 1 && r <= 10)
            {
                rank=  r.ToString();
            }
            else
            {
                var name = Enum.GetName(typeof(Rank), Rank);
                if(name.Length >=1 )
                rank = name[0]+"";
            }
            var suite = Enum.GetName(typeof(Suite),Suite);
            if(suite.Length>=1)
            return rank + suite[0];

            return "XX";
        }
    }
}